/*
** main.c for main_mario in /home/gjura_r//SDL/projet
** 
** Made by romain gjura
** Login   <gjura_r@epitech.net>
** 
** Started on  Fri Apr 12 11:34:33 2013 romain gjura
** Last update Fri Apr 12 17:21:34 2013 romain gjura
*/

#include <stdlib.h>
#include <stdio.h>
#include "./includes/map.h"
#include "./includes/draw.h"

int		main(int ac, char *av[])
{
  FILE		*fd;
  t_map		map;

  if (ac != 2)
    {
      fprintf(stderr, "Error: Usage: [./mario] [lvl_x.map]\n");
      return EXIT_FAILURE;
    }
  else
    {
      if ((fd = fopen(av[1], "r")) == NULL)
	{
	  fprintf(stderr, "Error while opening the file\n");
	  return EXIT_FAILURE;
	}
      count(fd, &map);
      fseek(fd, 0, 0);
      read_map(fd, &map);
      alloc_copy(&map);
      init_sdl(&map);
    }
  free_tab(map.tab, map.nb_line);
  free_tab(map.copy, map.nb_line);
  fclose(fd);
  return EXIT_SUCCESS;
}
